<?php

namespace app\admin\controller;

use app\admin\logic\GoodsLogic;
use think\Request;

class Good extends Base
{
    private $goodsLogic;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->goodsLogic = new GoodsLogic();
    }

    public function index()
    {
        return $this->fetch();
    }

    public function indexLog()
    {
        return $this->fetch();
    }

    //保存数据
    public function doAdd($param = '')
    {
        $carArr = json_decode($param, true);
        $carArr["branch_id"] = session("branch_id");
        $res = $this->goodsLogic->add($carArr);
        return $res;
    }

    //删除库存数据
    public function doDel($num)
    {
        return $this->goodsLogic->del($num);
    }

    //获取工单数据
    public function getGood($page = 1, $rows = 10, $q = '', $sidx = '', $sord = '')
    {
        $data = $this->goodsLogic->queryJqGrid('', $page, $rows, $q, $sidx, $sord);
        return $data;
    }

    //获取工单数据
    public function getGoodLog($page = 1, $rows = 10, $q = '', $sidx = '', $sord = '')
    {
        $data = $this->goodsLogic->queryJqGridLog('', $page, $rows, $q, $sidx, $sord);
        return $data;
    }

    public function pushGoods($num, $count)
    {
        return $this->goodsLogic->pop_push($num, 0, $count, session('id'));
    }

}


